package com.hua.ma.sang.gulimall.coupon.controller;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.hua.ma.sang.gulimall.common.entity.DataResponse;
import com.hua.ma.sang.gulimall.common.entity.Results;
import com.hua.ma.sang.gulimall.common.utils.R;
import com.huaxiaofan.contentAudit.service.AliYunContentAuditService;
import com.huaxiaofan.developer.aop.aspect.annotation.Developer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import com.hua.ma.sang.gulimall.coupon.entity.SmsCouponEntity;
import com.hua.ma.sang.gulimall.coupon.service.SmsCouponService;


/**
 * 优惠券信息
 *
 * @author huaxiaofan
 * @email a820372743@163.com
 * @date 2022-04-28 20:08:51
 */
@RestController
@RequestMapping("coupon/smscoupon")
public class SmsCouponController {
    @Autowired
    private SmsCouponService smsCouponService;

    @Autowired
    private AliYunContentAuditService aliYunContentAuditService;


    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("coupon:smscoupon:list")
    public ResponseEntity<DataResponse<SmsCouponEntity>> list(@RequestParam Map<String, Object> params){
        SmsCouponEntity smsCouponEntity = new SmsCouponEntity();
        smsCouponEntity.setCouponName("测试");
       return Results.success(smsCouponEntity);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @Developer(name = "huaxiaofan")
    //@RequiresPermissions("coupon:smscoupon:info")
    public ResponseEntity<DataResponse<SmsCouponEntity>> info(@PathVariable("id") Long id){
		SmsCouponEntity smsCoupon = smsCouponService.getCoupon(id);

        return Results.success(smsCoupon);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    //@RequiresPermissions("coupon:smscoupon:save")
    public ResponseEntity<DataResponse<SmsCouponEntity>> save(@RequestBody SmsCouponEntity smsCoupon){
		smsCouponService.saveCoupon(smsCoupon);
        return Results.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("coupon:smscoupon:update")
    public R update(@RequestBody SmsCouponEntity smsCoupon){
		smsCouponService.updateById(smsCoupon);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("coupon:smscoupon:delete")
    public R delete(@RequestBody Long[] ids){
		smsCouponService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
